package com.example.guarding_jc;

import android.database.sqlite.SQLiteDatabase;
import android.util.Log;

public class TosendTable {
	//Database table
	public static final String TABLE_TOSEND = "tosend";
	public static final String COLUMN_ID = "_id";
	public static final String COLUMN_SEQ = "seq";
	public static final String COLUMN_CHALLENGE = "challenge";
	public static final String COLUMN_MAC = "mac";
	public static final String COLUMN_UID = "uid";
	public static final String COLUMN_TIME = "scanned_time";
	public static final String COLUMN_IMEI = "imei";
	
	//Database creation SQL statement
	private static final String DATABASE_CREATE = "create table "
			+ TABLE_TOSEND
			+ "("
			+ COLUMN_ID + " integer primary key autoincrement, " 
			+ COLUMN_SEQ + " text not null, " 
			+ COLUMN_CHALLENGE + " text not null, "
		    + COLUMN_MAC + " text not null," 
		    + COLUMN_UID +  " text not null, "
		    + COLUMN_TIME + " text not null, "
		    + COLUMN_IMEI + " text not null "
		    + ");";
	public static void onCreate(SQLiteDatabase database) {
		Log.i("Create db", DATABASE_CREATE);
		database.execSQL(DATABASE_CREATE);
	}
	
	public static void onUpgrade(SQLiteDatabase database, int oldVersion, int newVersion) {
		Log.w(TosendTable.class.getName(), "Upgrading database from version "
		        + oldVersion + " to " + newVersion
		        + ", which will destroy all old data");
		database.execSQL("DROP TABLE IF EXISTS " + TABLE_TOSEND);
		onCreate(database);
	}
	
}
